
package system.base;

import framework.core.*;
import system.SelectManager;
import system.data.*;

/*
	Author    :Wing
	CreateTime:2008-02-20 17:30:49
*/
public class InHeadHis extends InHeadHisBase 
{

//----system generated start----// 	
public InHeadHis() 
{
	
}

private static void delete(DBConnection con,String id) throws Exception
{
	Conditions conditions = new Conditions();

	conditions.add(ID,id);
	
	delete(con,TABLE_NAME,conditions);
}
public static InHeadHis fetch()
{
	return new InHeadHis();
}
public static InHeadHis copy(InHeadHis srcObj)
{
	InHeadHis obj = fetch();
	obj.copyBase(srcObj);
	return obj;
}
public static InHeadHis fetch(DBConnection con,String id) throws Exception
{
	Conditions conditions = new Conditions();

	conditions.add(ID,id);
	
	return fetch(con,conditions);
}
public static InHeadHis fetch(DBConnection con,Conditions conditions) throws Exception
{
	DBResult result = null;
	try
	{
		result = DBEngine.doSelect(con,"select * from " + TABLE_NAME,conditions);
		java.sql.ResultSet rs = result.getRs();
		InHeadHis obj = null;
		if(rs.next())
		{
			obj = fetch(rs);
		}
		return obj;
	}
	finally
	{
		if(result!=null) result.clear() ;
	}
}
public static InHeadHis fetch(java.sql.ResultSet rs) throws Exception
{
	InHeadHis obj = new InHeadHis();
	obj.initObject(rs);
	return obj;
}
protected void getUnique(DBConnection con) throws Exception
{
		setId(DBEngine.getId(con));
}
//----system generated end----//



//----add by Wing start----//
public String viewBalanceFlag(DBConnection con) throws Exception
{
    return SelectManager.viewYesOrNoBalance(getBalanceFlag()+"");
}

public String viewInType(DBConnection con) throws Exception
{
    Conditions cs = new Conditions();
    cs.add(InoutType.CODE,getInType());
    InoutType obj = InoutType.fetch(con, cs);
    if (obj == null)
        return "";
    else
        return obj.viewName(con);
}

//----add by Wing end----//


//add by Jackey start --//
public String viewWarehouseName(DBConnection con) throws Exception
{
    String mReturn = "";
    Warehouse w = Warehouse.fetchByCode(con, getWarehouseCode());  
    if (w != null)
    {
        mReturn = w.getName();
    }
    return  mReturn;
}
// add by Jackey end

//add by Sindy start
public static InHeadHis fetchByInBillId(DBConnection con,String id) throws Exception
{
    Conditions conditions = new Conditions();

    conditions.add(ID,id);
    
    return fetch(con,conditions);
}
//add by Sindy end
}

